package com.dtwave.cfstreaming.update.dimtableupdate;

import com.alibaba.fastjson.JSONObject;
import com.dtwave.cfstreaming.utils.HbaseUtils;
import com.dtwave.utils.JsonUtils;
import org.apache.hadoop.hbase.client.Connection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class DimTableUpdate {
    private static Logger LOGGER = LoggerFactory.getLogger(DimTableUpdate.class);

    public static void update(Connection hbaseClient, JSONObject after) {
        String rowKey = JsonUtils.getString(after, true, "rowKey");
        try {
            if(rowKey.length()!=0){
                JSONObject jsonObject = new JSONObject();
                String value = JsonUtils.getString(after, true, "字段名称");
                jsonObject.put("hbase中的字段名",value);
                HbaseUtils.put(hbaseClient,"habse表名称",rowKey,"列簇",jsonObject);
            }
        }catch (Exception e){
            LOGGER.error("更新失败{0}",e);
        }
    }
}
